#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int Area(int x1, int y1, int x2, int y2)
{
    return (x2 - x1) * min(y1, y2);
}
int maxArea(vector<int>& height) {
    int maxarea = 0;
    int left = 0, right = height.size() - 1;
    while (left != right)
    {
        maxarea = max(Area(left, height[left], right, height[right]), maxarea);
        if (height[left] < height[right])
            left++;
        else
            right--;
    }
    return maxarea;
}
int main()
{
    vector<int> height{ 1,8,6,2,5,4,8,3,7 };
    int area = maxArea(height);
    cout << area;
	return 0;
}